package com.dunshan.md;

import org.apache.commons.codec.digest.DigestUtils;

import java.util.Random;


/**
 * @author
 * @program: dunshan-pef
 * @description: 加密方法
 * @date 2022-05-11 14:20:49
 */
public class Md5Encrypt {


    /**
     * MD5加密
     *
     * @param str  加密字符串
     * @param salt 加密盐
     * @return 16进制加密字符串
     * @describe 借助apache工具类DigestUtils实现
     */
    public static String encryptToMD5(String str, String salt) {
        try {
            Random random = new Random();
            Thread.sleep(random.nextInt(6000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return DigestUtils.md5Hex(str + DigestUtils.md5Hex(salt));
    }


    public static void main(String[] args) {
        System.out.println(encryptToMD5("d7MBbcgSIH", "Z28a"));
    }

}
